
package petrivis;

import javax.swing.JFrame;
import petrivis.model.PetriNet;
import petrivis.view.PNDisplay;
import petrivis.view.PNVisualization;

/**
 * Class to try the Petri Net Display Alone
 * @author Jorge Munoz
 */
public class FooDisplay {

    public static void main(String argv[]) {

        // 1. Load the data
        PetriNet pN = new PetriNet();
        pN.addPlace("p0");
        pN.addTransition("a");
        pN.addArc("p0", "a");
        pN.addPlace("p1");
        pN.addArc("a", "p1", 2);
        pN.addPlace("p2");
        pN.addArc("a", "p2");
        pN.setMarking("p0", 2);
        pN.setMarking("p1", 1);
        pN.setMarking("p2", 0);
        

        // 2. prepare the visualization
        PNVisualization pnV = new PNVisualization(pN);

        //3. prepare the Display
        PNDisplay pnD = new PNDisplay();
        pnD.setVisualization(pnV);
        pnD.setSize(700, 700);
        pnD.pan(350, 350);	// pan to the middle
        pnD.setHighQuality(true);

        // 4. launch the visualizer in a JFrame
        JFrame frame = new JFrame("Petri Net Foo Display");
        /* frame is the main window */

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.add(pnD);
        /* add the display (which holds the visualization) to the window */

        frame.pack();
        frame.setVisible(true);

        /* start the visualization working */
        pnV.run("draw");

    }


}
